<?php
namespace app\common\model;
use think\Exception;
use think\Model;
class Base extends Model
{
    /* 获取单行数据 */
    public function getOne ($where) {
        $obj = $this->where($where)->find();
        if($obj) {
            return $obj->toArray();
        }
        return false;
    }

    /* 获取列表数据 */
    public function getList ($where=1,$orderby='') {
        $obj = $this->where($where)->order($orderby)->select();
        if($obj) {
            return $obj->toArray();
        }
        return false;
    }

    /* 分页获取数据 */
    public function getPage ($where,$page=1,$size=20,$orderby='',$condtion='',$filed='') {
        try{
            $obj = $this->field($filed)->where($where)->page($page,$size)->order($orderby)->select();
            if($obj) {
                return $obj->toArray();
            }else{
                return false;
            }
        }catch (Exception $ex){
            return false;
        }

    }
}
